﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Text;
using Token.Piker.DAL;
using  Token.Piker.Model;

namespace Token.Piker.Core.Tag
{
    public class TagProxy
    {
        
        public static List< Token.Piker.Model.Tag> GetTagList(string where)
        {
            Token.Piker.DAL.TagDAL dal = new Token.Piker.DAL.TagDAL();

            DataTable dt = dal.GetList(where).Tables[0];
            List< Token.Piker.Model.Tag> modelList = new List< Token.Piker.Model.Tag>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                 Token.Piker.Model.Tag model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new  Token.Piker.Model.Tag();
                    if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    if (dt.Rows[n]["TagName"] != null && dt.Rows[n]["TagName"].ToString() != "")
                    {
                        model.TagName = dt.Rows[n]["TagName"].ToString();
                    }
                    if (dt.Rows[n]["Flag"] != null && dt.Rows[n]["Flag"].ToString() != "")
                    {
                        model.Flag = int.Parse(dt.Rows[n]["Flag"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }
    }
}
